feat(gmail): add list_emails_structured tool for programmatic email retrieval#115
Merged
dimavedenyapin merged 2 commits intomainfrom Apr 3, 2026
Merged
feat(gmail): add list_emails_structured tool for programmatic email retrieval#115dimavedenyapin merged 2 commits intomainfrom
dimavedenyapin merged 2 commits intomainfrom
Conversation
…etrieval Add a new `list_emails_structured` tool that returns emails as structured JSON, designed for consumption by workflow-builder trigger nodes and automation workflows. Unlike `read_emails` which returns human-readable text, this tool outputs machine-parseable JSON with typed fields. Features: - Structured JSON output with emails array, resultCount, and query - Optional filters: query, label_ids, max_results (capped at 100) - Toggleable body and attachment inclusion via include_body / include_attachments_info - Extra header extraction via include_headers parameter - Each email includes: id, threadId, historyId, from, to, cc, bcc, subject, date, snippet, labels, isUnread, messageId Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…parate tool Replace the standalone list_emails_structured tool with an output_format parameter on the existing read_emails tool. When output_format='structured' is passed, read_emails returns structured JSON; otherwise it returns the original human-readable text format (backward compatible). Also adds label_ids and include_headers params to read_emails for structured mode filtering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
output_formatparameter to the existingread_emailstool — when set to"structured", returns machine-parseable JSON instead of human-readable textoutput_format(or with"text"), behavior is unchangedlabel_idsandinclude_headersoptional params for structured mode filteringUsage
Default (text) — unchanged behavior
{ "query": "is:unread", "max_results": 5 }Returns:
"Found 5 emails:\n\nID: msg_001\nFrom: ..."Structured JSON output
{ "query": "is:unread", "output_format": "structured", "label_ids": ["INBOX"], "max_results": 10 }Returns:
{ "emails": [ { "id": "msg_001", "threadId": "thread_001", "historyId": "12345", "from": "alice@example.com", "to": "bob@example.com", "cc": "", "bcc": "", "subject": "Hello", "date": "Mon, 31 Mar 2026 10:00:00 +0000", "snippet": "...", "labels": ["INBOX", "UNREAD"], "isUnread": true, "messageId": "<abc@mail.gmail.com>", "body": { "text": "...", "html": "..." }, "attachments": [{ "filename": "...", "mimeType": "...", "size": 1024, "attachmentId": "..." }] } ], "resultCount": 1, "query": "is:unread" }New optional parameters on
read_emailsoutput_format"text"|"structured""text")label_idsstring[]include_headersstring[]Test plan
🤖 Generated with Claude Code